home *** CD-ROM | disk | FTP | other *** search
/ Internet Publisher's Toolbox 2.0 / Internet Publisher's Toolbox.iso / internet / ntserver / wtsource / ustubs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-05  |  4.0 KB  |  179 lines

  1. /* WIDE AREA INFORMATION SERVER SOFTWARE        
  2.    No guarantees or restrictions.  See the readme file for the full standard 
  3.    disclaimer.  
  4.    4.14.90      Harry Morris, morris@think.com
  5. */
  6.  
  7. /* Copyright (c) CNIDR (see ../COPYRIGHT) */
  8.  
  9.  
  10. #ifndef lint
  11. static char *RCSid = "$Header: /usr/users/freewais/FreeWAIS-0.1/ir/ustubs.c,v 1.1 1993/02/16 15:05:35 freewais Exp $";
  12. #endif
  13.  
  14. /* Change log:
  15.  * $Log: ustubs.c,v $
  16.  * Revision 1.1  1993/02/16  15:05:35  freewais
  17.  * Initial revision
  18.  *
  19.  * Revision 1.4  92/05/06  17:35:13  jonathan
  20.  * Modified some #if's for NeXT and Mach.
  21.  * 
  22.  * Revision 1.3  92/03/06  11:08:49  jonathan
  23.  * fixed incompatible return type error in HP version of getwd.  Thanks to
  24.  * cshotton@oac.hsc.uth.tmc.edu.
  25.  * 
  26.  * Revision 1.2  92/02/12  13:54:29  jonathan
  27.  * Added "$Log" so RCS will put the log message in the header
  28.  * 
  29.  * 
  30. */
  31.  
  32. /*----------------------------------------------------------------------*/
  33. /* stubs for silly non-ansi c compilers                                 */
  34. /*----------------------------------------------------------------------*/
  35.  
  36. #include "ustubs.h"
  37. #include "cutil.h" /* for substrcmp and NULL */
  38.  
  39.  
  40. #ifdef WIN32
  41. #include <string.h>
  42.  
  43. char *bcopy(src, dest, len)
  44. char *dest, *src;
  45. int len;
  46. {
  47.   return((char*)memmove(dest, src, len));
  48. }
  49. #endif
  50.  
  51. /*----------------------------------------------------------------------*/
  52. /* believe it or not, HP does not have bzero or bcopy                   */
  53.  
  54. #ifdef hpux
  55.  
  56. void bzero(ptr, len)
  57. char *ptr;
  58. int len;
  59. {
  60.   long count;
  61.   for (count = 0; count < len; count++){
  62.     *(char*)(ptr + count) = 0;
  63.     }
  64. }
  65.  
  66. char *bcopy(src, dest, len)
  67. char *dest, *src;
  68. int len;
  69. {
  70.   return((char*)memmove(dest, src, len));
  71. }
  72.  
  73. char *getwd(pathname)
  74. char *pathname;
  75. {
  76.   return((char*)getcwd(pathname, MAX_FILENAME_LEN));
  77. }
  78.  
  79. #endif 
  80.  
  81. #ifdef SYSV
  82. #include <prototypes.h> /* may be XENIX dependent! */
  83. char *
  84. getwd(pathname)
  85. char *pathname;
  86. {
  87.   return(getcwd(pathname, MAX_FILENAME_LEN));
  88. }
  89. #endif /* def SYSV */
  90.  
  91. /*----------------------------------------------------------------------*/
  92.  
  93. #ifndef ANSI_LIKE   /* memmove is an ANSI function not defined by K&R */
  94. #ifndef hpux /* but HP defines it */
  95. void*
  96. memmove(str1,str2,n)
  97. void* str1;
  98. void* str2;
  99. size_t n;
  100. {
  101. #ifdef M_XENIX
  102.   memcpy((char*)str2,(char*)str1,(long)n); /* hope it works! */
  103. #else /* ndef M_XENIX */
  104.   bcopy((char*)str2,(char*)str1,(long)n);
  105. #endif /* ndef M_XENIX */
  106.   return(str1);
  107. }
  108. #endif /* ndef hpux */
  109.  
  110. #else /* ansi is defined */
  111.  
  112. #ifdef __GNUC__ /* we are ansi like, are we gcc */
  113.  
  114. #if !(defined(NeXT) || defined(Mach)) /* and we are not on a next ! */
  115.  
  116. void*
  117. memmove(str1,str2,n)
  118. void* str1;
  119. void* str2;
  120. size_t n;
  121. {
  122.   bcopy((char*)str2,(char*)str1,(long)n);
  123.   return(str1);
  124. }
  125.  
  126. #endif /* not NeXT or Mach */
  127.  
  128. #endif /* __GNUC__ */
  129.  
  130. #endif /* else ndef ANSI_LIKE */
  131.  
  132. /*----------------------------------------------------------------------*/
  133.  
  134. #ifndef ANSI_LIKE  
  135.  
  136. /* atoi is not defined k&r. copied from the book */
  137. long atol(s)
  138. char *s;
  139. {
  140.   long i, n, sign;
  141.   for(i=0; s[i]==' ' || s[i]== 'n' || s[i]=='t'; i++)
  142.     ;                           /* skip white space */
  143.   sign = 1;
  144.   if (s[i] == '+' || s[i] == '-')
  145.     sign = (s[i++]=='+') ? 1 : -1;
  146.   for (n=0; s[i] >= '0' && s[i] <= '9'; i++)
  147.     n= 10 * n + s[i] - '0';
  148.   return(sign * n);
  149. }
  150.  
  151. /*----------------------------------------------------------------------*/
  152.  
  153. char *strstr(src,sub)
  154. char *src;
  155. char *sub;
  156. {
  157.   /* this is a poor implementation until the ANSI version catches on */
  158.   char *ptr;
  159.   for(ptr = src; (long)ptr <= (long)src + strlen(src) - strlen(sub); ptr++){
  160.     if(substrcmp(ptr, sub))
  161.       return(ptr);
  162.   }
  163.   return(NULL);
  164. }
  165.  
  166. /*----------------------------------------------------------------------*/
  167.  
  168. int remove(filename)
  169. char *filename;
  170. {
  171.   return(unlink(filename));
  172. }
  173.  
  174. /*----------------------------------------------------------------------*/
  175.  
  176. #endif /* ndef ANSI_LIKE */
  177.  
  178.  
  179.